#include "ManualHash.h"
#include "lookup3.c"

#include <cstring>
#include <string>
#include <iostream>

#define KEY 0

using namespace std ;

ManualHash::ManualHash()
{
}

ManualHash::~ManualHash()
{
}

uint ManualHash::ToInteger(const char * word)
{
	return hashlittle(word,strlen(word),KEY);
}

uint ManualHash::ToInteger(const string word)
{
	return hashlittle(word.c_str(),word.size(),KEY);
}

/*
uint ManualHash::ToInteger(const char * word)
{
	uint number =0;
	int n = strlen(word);
	for(int i=n-1;i>=0;i--)
	{
		number *=27;
		short digit = (short)(tolower(word[i]) -'a'+ 1);
//		cout << "digito lido " << digit << endl;		
		number +=digit;
//		cout << "number " << number << endl;
	}
	return number;
}

uint ManualHash::ToInteger(const string word)
{
	return ManualHash::ToInteger(word.c_str());
}

string ManualHash::ToString(int number)
{
	string s = "";
	
	for(;number>=1;number /= 27)
	{
		char c = (char)(number%27);
		c += 'a' -1;
//		cout << "caracter: " <<  c << endl;
		s.append(1,c);
//		cout << "string " << s  << endl;
	}	
	
	return s;	
}

char* ManualHash::ToChar(int number)
{
	return const_cast<char *>(ManualHash::ToString(number).c_str());
}
*/
